#include "Camera.h"

Camera::Camera(
  const Vector& e,
  const Vector& g,
  const Vector& up,
  const fp s
)
{  
  p.o = e;
  p.InitAsWV(g*-1.0f, up);  

  width=4;
  height=4;
  
  c = p.o + p.u*-(width/2.0f) + p.v*-(height/2.0f) - p.w*s;
  a = p.u*(float)width;
  b = p.v*(float)height;
};

//Camera::Camera(const Camera& c) { Camera(c.e, c.g, c.up); };

Ray Camera::GetRay(const ui32 x, const ui32 y)
{
  /*float x0 = (float)x/(float)width,
        y0 = (float)(4-y)/(float)height;*/

  float a0 = (float)x+0.5f/(float)width,
        b0 = (float)y+0.5f/(float)height;
  return Ray(p.o, c + a*a0 + b*b0);
};
